package com.njwb.day15.zqzb.game;

import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.text.SimpleDateFormat;

public class Util {
    public String time(long data){
        return time(data,"yyyy-MM-dd HH:mm:ss");
    }
    public String time(long data,String pattern){
        SimpleDateFormat sdf=new SimpleDateFormat(pattern);
        return sdf.format(data);
    }
    public static final Writer write;
    static {
        Writer w = null;
        try {
            w = new FileWriter("src/com/njwb/game/score.txt", true);
        } catch (IOException e) {
            e.printStackTrace();
        }
        write = w;
    }
    public void writeTxt(String txt){
        try {
            write.write(txt);
            write.flush();  // 保证写入立即生效
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
